package com.joysw.ui;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.EditText;
import android.widget.Toast;
import butterknife.ButterKnife;
import butterknife.InjectView;

import com.joysw.R;
import com.joysw.utils.ConstantUtil;
import com.joysw.view.TitleBarView;


/**
 * 
* @Title: MainActivity.java 
* @Package com.joysw.ui 
* @Description: 修改个人名字页面
* @author LIMINGYAN  
* @date 2015年3月28日 上午7:39:14 
* @version V1.0
 */
public class ModifyAccountNameActivity extends BaseActivity{
	private static final String TAG = "ModifyAccountNameActivity";
	@InjectView(R.id.modify_name_title_bar)
	TitleBarView title_bar_view;
	@InjectView(R.id.et_username)
	EditText et_username;
	private String type;
	
	 @Override
	    protected void onCreate(Bundle arg0) {
	    	// TODO Auto-generated method stub
	    	super.onCreate(arg0);
	    	setContentView(R.layout.activity_modify_account_name);
	    	ButterKnife.inject(this);
	    	
	    	initView();
	    }

	private void initView() {
		
		
		String username = (String) getIntent().getExtras().get("data");
		type = (String) getIntent().getExtras().get("type");
		title_bar_view.setTitleText(R.string.modify_name_title);
		title_bar_view.setBtnLeft(R.drawable.ic_back, R.string.back);
		title_bar_view.setBtnRightText(R.string.modify_right_text);
		
		
		
		et_username.setText(username);
		title_bar_view.setBtnLeftOnclickListener(new OnClickListener() {

			@Override
			public void onClick(View arg0) {
				finish();
			}
		});
		
		title_bar_view.setBtnRightOnclickListener(new OnClickListener() {
			
			@Override
			public void onClick(View arg0) {
				if(et_username.getText().toString().trim().equals("")){
					Toast.makeText(ModifyAccountNameActivity.this, "用户名不能为空", Toast.LENGTH_LONG).show();
					return;
				}
				Intent data=new Intent(); 
				data.putExtra("reset_name", et_username.getText().toString());
				if(type.equals("name")){
					setResult(ConstantUtil.NAME, data); 
				}
				else{
					setResult(ConstantUtil.QQ, data); 
				}
				finish();
			}
		});
		
	}
}
